﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Game_MVC3.Code
{
    public class Helper
    {

        #region HTML

        /// <summary>
        /// Returns a Jquery UI Div with an error message
        /// </summary>
        /// <param name="text">Error Message</param>
        public static string HtmlError(string text)
        {
            string s = "<div class=\"ui-widget\" style=\"width: 350px; height: auto;\">" + Environment.NewLine;
            s += "  <div class=\"ui-state-error ui-corner-all\" style=\"padding: 0 .7em;\">" + Environment.NewLine;
            s += "      <p><span class=\"ui-icon ui-icon-alert\" style=\"float: left; margin-right: .3em;\"></span>" + Environment.NewLine;
		    s += "      " + text + Environment.NewLine;
			s += "  </div>" + Environment.NewLine;
			s += "</div>" + Environment.NewLine;

            return s;
        }

        #endregion

        #region Date

        /// <summary>
        /// Gets a date string to display at the News Page
        /// </summary>
        /// <param name="date">Date to transform</param>
        public static string ToNewsDate(DateTime date)
        {
            string[] months = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
            string day = date.Day.ToString();
            switch (day.Last())
            {
                case '1': day += "st"; break;
                case '2': day += "nd"; break;
                case '3': day += "nd"; break;
                default: day += "th"; break;
            }
            return months[date.Month] + " " + day + ", " + date.Year;
        }

        #endregion
    }
}